package com.jinmdz.fmis.dao.dao.provider;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.jdbc.SQL;

/**
 * 整容项目Provider
 *
 * @author LiCongLu
 * @date 2020-02-19 16:38
 */
public class FaceLiftItemProvider {

    /**
     * 按照业务编码查询整容项目
     *
     * @param businessCode 业务编码
     * @return
     * @author LiCongLu
     * @date 2020-02-13 18:39
     */
    public String listFaceLiftChargeByBusinessCode(@Param("businessCode") String businessCode) {
        return new SQL() {
            {
                StringBuilder builder = new StringBuilder();
                builder.append(" face_lift_item.id,face_lift_item.business_code,face_lift_item.service_item_id,require_finish_time,reality_finish_time,finish_user_id,process_state_code,face_lift_item.random_code,charge_id,face_lift_item.version");
                builder.append(" ,service_item.item_name,charge_item.item_price,charge_item.item_number,charge_item.item_unit,charge_item.item_charge");
                builder.append(" ,discount_charge,benefit_charge,reality_charge,charge_time,as_unsettled,as_settled,charge_item.version as charge_version");
                SELECT(builder.toString());
                FROM(" face_lift_item ");
                JOIN(" charge_item on charge_item.id = face_lift_item.charge_id ");
                JOIN(" service_item on service_item.id = charge_item.service_item_id ");
                WHERE(" face_lift_item.deleted = 0 and charge_item.deleted = 0 ");
                WHERE(" charge_item.business_code = #{businessCode} ");
                WHERE(" face_lift_item.business_code = #{businessCode} ");
                ORDER_BY(" service_item.sort ");
            }
        }.toString();
    }
}
